package cn.toma.common.enumtype.status.member;

import cn.toma.common.enumtype.status.IEnum;
import com.alibaba.fastjson.annotation.JSONType;
import com.fasterxml.jackson.annotation.JsonFormat;

/**
 * @Author: zqx
 * @Date: 2019-08-02 14:08
 * @Description:
 */
@JSONType(serializeEnumAsJavaBean = true)
@JsonFormat(shape = JsonFormat.Shape.OBJECT)
public enum TypeEnum implements IEnum<Integer>
{

	/**
	 * 正常状态
	 */
	NORMAL(1, "普通用户", "member_type"),
	VIP(2, "VIP用户", "member_type"),
	UNDEFINED(-1, "未定义状态", "member_type"),
	;


	/**
	 * 根据状态码 获取枚举类型
	 *
	 * @param code
	 * @return
	 */
	public static TypeEnum getStatusByCode(Integer code)
	{
		for (TypeEnum statusEnumType : values()) {
			if (statusEnumType.getCode().equals(code)) {
				return statusEnumType;
			}
		}
		return UNDEFINED;
	}

	private Integer code;
	private String desc;
	private String dict;


	TypeEnum(Integer code, String desc, String dict)
	{
		this.code = code;
		this.desc = desc;
		this.dict = dict;
	}


	public String getDesc()
	{
		return desc;
	}

	public String getDict()
	{
		return dict;
	}


	@Override
	public Integer getCode()
	{
		return code;
	}}
